package com.fairytask.tools
{
	import com.fairytask.data.ViewObject;
	import com.fairytask.engine.define.MoneyDefine;
	import com.fairytask.resource.StaticIni;
	
	public class TipsTools
	{
		public static var PHYSICAL	:int	=	0; //物理
		public static var MAGICAL		:int	=	1; //法术
		
		public function TipsTools()
		{
		}
		
		/**
		 * 客户端模拟视图对象数据封装 
		 * @param viewObject
		 * @param pList
		 * @param type 0:一般模块(排行榜\聊天窗口) 1:邮件模块
		 * 
		 */		
		public static function DataHandler(viewObject:ViewObject,pList:Array,type:int=0):void
		{
			if(type == 1)//邮件模块需数量
			{
				viewObject.HandleProperties("Amount",int(pList.shift()));
			}
			viewObject.HandleProperties("ConfigID",int(pList.shift()));
			viewObject.HandleProperties("Color",int(pList.shift()));
			viewObject.HandleProperties("Star",int(pList.shift()));
			viewObject.HandleProperties("Identify",int(pList.shift()));
			viewObject.HandleProperties("EquipQuality",int(pList.shift()));
			viewObject.HandleProperties("EquipType",int(pList.shift()));
			viewObject.HandleProperties("PhyDamage",int(pList.shift()));
			viewObject.HandleProperties("PhyDamageAdd",int(pList.shift()));
			viewObject.HandleProperties("PhyDamageMul",int(pList.shift()));
			viewObject.HandleProperties("Level",int(pList.shift()));
			viewObject.HandleProperties("Stag",int(pList.shift()));
			viewObject.HandleProperties("PetType",int(pList.shift()));
			viewObject.HandleProperties("HP",int(pList.shift()));
			viewObject.HandleProperties("MaxHP",int(pList.shift()));
			viewObject.HandleProperties("MaxHPAdd",int(pList.shift()));
			viewObject.HandleProperties("Str",int(pList.shift()));
			viewObject.HandleProperties("StrAdd",int(pList.shift()));
			viewObject.HandleProperties("Ing",int(pList.shift()));
			viewObject.HandleProperties("IngAdd",int(pList.shift()));
			viewObject.HandleProperties("Spi",int(pList.shift()));
			viewObject.HandleProperties("SpiAdd",int(pList.shift()));
			viewObject.HandleProperties("Dex",int(pList.shift()));
			viewObject.HandleProperties("DexAdd",int(pList.shift()));
			viewObject.HandleProperties("Hit",int(pList.shift()));
			viewObject.HandleProperties("HitAdd",int(pList.shift()));
			viewObject.HandleProperties("Dodge",int(pList.shift()));
			viewObject.HandleProperties("DodgeAdd",int(pList.shift()));
			viewObject.HandleProperties("FightSpeed",int(pList.shift()));
			viewObject.HandleProperties("FightSpeedAdd",int(pList.shift()));
			viewObject.HandleProperties("ST",int(pList.shift()));
			viewObject.HandleProperties("MagDamage",int(pList.shift()));
			viewObject.HandleProperties("MagDamageAdd",int(pList.shift()));
			viewObject.HandleProperties("MagDamageMul",int(pList.shift()));
			viewObject.HandleProperties("PhyDefAdd",int(pList.shift()));
			viewObject.HandleProperties("PhyDef",int(pList.shift()));
			viewObject.HandleProperties("MagDef",int(pList.shift()));
			viewObject.HandleProperties("MagDefAdd",int(pList.shift()));
			viewObject.HandleProperties("AddProp",pList.shift());
			viewObject.HandleProperties("AddRefineProp",pList.shift());
		}
		
		/**
		 * 宠物蛋数据封装 
		 * @param viewObject
		 * @param pList
		 * @param type
		 * 
		 */
		public static function EggDataHandler(viewObject:ViewObject,pList:Array,type:int=0):void
		{
			viewObject.HandleProperties("ConfigID",int(pList.shift()));
			viewObject.HandleProperties("Quality",int(pList.shift()));
			viewObject.HandleProperties("PetType",int(pList.shift()));
			viewObject.HandleProperties("Level",int(pList.shift()));
			viewObject.HandleProperties("NeedLevel",int(pList.shift()));
			viewObject.HandleProperties("Life",int(pList.shift()));
			viewObject.HandleProperties("Character",int(pList.shift()));
			viewObject.HandleProperties("Loyal",int(pList.shift()));
			viewObject.HandleProperties("WuXing",int(pList.shift()));
			
			viewObject.HandleProperties("HP",int(pList.shift()));
			viewObject.HandleProperties("HPAdd",int(pList.shift()));
			viewObject.HandleProperties("MaxHP",int(pList.shift()));
			viewObject.HandleProperties("MaxHPAdd",int(pList.shift()));
			viewObject.HandleProperties("MP",int(pList.shift()));
			viewObject.HandleProperties("MPAdd",int(pList.shift()));
			viewObject.HandleProperties("MaxMP",int(pList.shift()));
			viewObject.HandleProperties("MaxMPAdd",int(pList.shift()));
			
			viewObject.HandleProperties("MinPhyDamage",int(pList.shift()));
			viewObject.HandleProperties("MaxPhyDamage",int(pList.shift()));
			viewObject.HandleProperties("PhyDamageAdd",int(pList.shift()));
			viewObject.HandleProperties("PhyDamage",int(pList.shift()));
			viewObject.HandleProperties("PhyDamageMul",int(pList.shift()));
			viewObject.HandleProperties("MinPhyDamageAdd",int(pList.shift()));
			viewObject.HandleProperties("MaxPhyDamageAdd",int(pList.shift()));
			viewObject.HandleProperties("MinMagDamage",int(pList.shift()));
			viewObject.HandleProperties("MaxMagDamage",int(pList.shift()));
			viewObject.HandleProperties("MagDamageAdd",int(pList.shift()));
			viewObject.HandleProperties("MagDamage",int(pList.shift()));
			viewObject.HandleProperties("MagDamageMul",int(pList.shift()));
			viewObject.HandleProperties("MinMagDamageAdd",int(pList.shift()));
			viewObject.HandleProperties("MaxMagDamageAdd",int(pList.shift()));
			
			viewObject.HandleProperties("PhyDef",int(pList.shift()));
			viewObject.HandleProperties("PhyDefAdd",int(pList.shift()));
			viewObject.HandleProperties("MagDef",int(pList.shift()));
			viewObject.HandleProperties("MagDefAdd",int(pList.shift()));
			viewObject.HandleProperties("FightSpeed",int(pList.shift()));
			viewObject.HandleProperties("FightSpeedAdd",int(pList.shift()));
			viewObject.HandleProperties("Str",int(pList.shift()));
			viewObject.HandleProperties("StrAdd",int(pList.shift()));
			viewObject.HandleProperties("PhyAptitude",int(pList.shift()));
			viewObject.HandleProperties("Spi",int(pList.shift()));
			viewObject.HandleProperties("SpiAdd",int(pList.shift()));
			viewObject.HandleProperties("MagAptitude",int(pList.shift()));
			viewObject.HandleProperties("Ing",int(pList.shift()));
			viewObject.HandleProperties("IngAdd",int(pList.shift()));
			viewObject.HandleProperties("DefAptitude",int(pList.shift()));
			
			viewObject.HandleProperties("Sta",int(pList.shift()));
			viewObject.HandleProperties("StaAdd",int(pList.shift()));
			viewObject.HandleProperties("SpiAptitude",int(pList.shift()));
			viewObject.HandleProperties("Dex",int(pList.shift()));
			viewObject.HandleProperties("DexAdd",int(pList.shift()));
			viewObject.HandleProperties("DexAptitude",int(pList.shift()));
			viewObject.HandleProperties("GrowAptitude",int(pList.shift()));
			viewObject.HandleProperties("AptitudePoint",int(pList.shift()));
			viewObject.HandleProperties("CurSkillSpace",int(pList.shift()));
			viewObject.HandleProperties("Color",int(pList.shift()));
			viewObject.HandleProperties("BindType",int(pList.shift()));
			viewObject.HandleProperties("NameID",int(pList.shift()));
			viewObject.HandleProperties("HasLearnSkill",String(pList.shift()));
		}
		
		/**
		 * 宠物类型
		 * @param type
		 * @return 
		 * 
		 */
		public static function petType(type:int):String
		{
			if(type < 1 || type > 5)
			{
				type	=	1;
			}
			var typeList	:Array	=	StaticIni.getIniList("PetType");//ClientConfig.ini配置文件
			return (StaticIni.getSwfLangStr(typeList[type]));
		}
		
		/**
		 * 文字链接颜色 
		 * @param str
		 * @param color
		 * @param size
		 * @return 
		 * 
		 */
		public static function link_color(str:String,color:int,size:uint=12):String
		{
			if(color < 1 || color >6)
			{
				color	=	1;
			}
			var colorList	:Array	=	StaticIni.getIniList("equip_color_table");//ClientConfig.ini配置文件
			return ("<font size='"+size+"'>" + StaticIni.getSwfLangStrVar(colorList[color],[str])+"</font>");
		}
		
		/**
		 * 文字颜色 
		 * @param str
		 * @param color
		 * @return 
		 * 
		 */
		public static function onlyColor(str:String,color:int):String
		{
			if(color < 1 || color >7)
			{
				color	=	1;
			}
			var colorList	:Array	=	StaticIni.getIniList("equip_color_table");//ClientConfig.ini配置文件
			return (StaticIni.getSwfLangStrVar(colorList[color],[str]));
		}
		
		/**
		 *	获取单位 
		 * @param value
		 * @return 
		 * 
		 */		
		public static function getUnit(value:int):String
		{
			var str	:String	=	"";
			switch(value)
			{
				case MoneyDefine.CAPITAL_TYPE_SILVER:
					str	= StaticIni.getSwfLangStr("1000000298");
					break;
				case MoneyDefine.CAPITAL_TYPE_BINDSILVER:
					str	= StaticIni.getSwfLangStr("1000000299");
					break;
				case MoneyDefine.CAPITAL_TYPE_GOLD:
					str	= StaticIni.getSwfLangStr("1000000300");
					break;
				case MoneyDefine.CAPITAL_TYPE_BINDGOLD:
					str	= StaticIni.getSwfLangStr("1000000301");
					break;
				case MoneyDefine.CAPITAL_TYPE_SCORE:
					str	= StaticIni.getSwfLangStr("1000000302");
					break;
				case MoneyDefine.CAPITAL_TYPE_CONTRIBUTE:
					str	=	StaticIni.getSwfLangStr("1000000303");
					break;
				case MoneyDefine.CAPITAL_TYPE_SHELL:
					str	=	StaticIni.getSwfLangStr("1000000304");
					break;
				case MoneyDefine.CAPITAL_TYPE_SPIRIT:
					str	=	StaticIni.getSwfLangStr("1000000305");
					break;
			}
			return str;
		}
		
		/**
		 * 根据数据组织文字 
		 * @param pConfigID
		 * @param pKeyArr [damageMin,damageMax,damageAdd,damageMinAdd,damageMaxAdd]
		 * @param pStrKey
		 * @param pData
		 * @return 
		 * 
		 */
		public static function formatDamage(pConfigID:String,pType:int,pData:ViewObject):String
		{
			var pKeyArr	:Array	=	[];
			var pStrKey	:String	=	"";
			if(pType==PHYSICAL)
			{
				pStrKey	=	"1000000306";
				pKeyArr	=	["MinPhyDamage","MaxPhyDamage","PhyDamageAdd","MinPhyDamageAdd","MaxPhyDamageAdd"];
			}
			else
			{
				pStrKey	=	"1000000307";
				pKeyArr	=	["MinMagDamage","MaxMagDamage","MagDamageAdd","MinMagDamageAdd","MaxMagDamageAdd"];
			}
			
			var str			:String	=	"";
			var damageMin	:int	=	0;
			var damageMax	:int	=	0;
			var damageAdd	:int	=	0;
			var damageMinAdd	:int	=	0;
			var damageMaxAdd	:int	=	0;
			if(null		==	pData)
			{
				//物理攻击力附加值
				damageMin	=	int(StaticIni.getIniVar(pConfigID,pKeyArr[0]));
				damageMax	=	int(StaticIni.getIniVar(pConfigID,pKeyArr[1]));
			}
			else
			{
				damageAdd		=	pData.GetPropertiesEx(pKeyArr[2]);
				damageMin		=	pData.GetProperties(pKeyArr[0]);
				damageMax		=	pData.GetProperties(pKeyArr[1]);
				
				damageMinAdd		=	pData.GetPropertiesEx(pKeyArr[3]);
				damageMaxAdd		=	pData.GetPropertiesEx(pKeyArr[4]);
			}
			
			//当伤害为范围时
			if((damageMin+damageMax)>0)
			{
				str	+=	StaticIni.getSwfLangStrVar(pStrKey,[damageMin+"~"+damageMax]);
				if((damageAdd+damageMinAdd+damageMaxAdd)>0)
				{
					var addStr	:String	=	"";
					addStr	=	"("+(damageAdd+damageMinAdd)+"~"+(damageAdd+damageMaxAdd)+")";
					str	+=	TipsTools.link_color(addStr,2);
				}
				
				str +=	"<br/>";
			}else
			{
				if(damageAdd>0)//固定值
				{
					str += StaticIni.getSwfLangStrVar(pStrKey,["+"+damageAdd.toString()]);
					str += "<br/>";
				}
			}
			
			return str;
		}
		
		/**
		 * 根据不同的装备等级来显示不同的名字 
		 * @param type
		 * @return 
		 * 
		 */
		public static function getRefineName(type:int):String
		{
			var str:String	=	""
			switch(type)
			{
				case 1:
					str	=	StaticIni.getSwfLangStr("1000000433");
					break;
				case 2:
					str	=	StaticIni.getSwfLangStr("1000000434");
					break;
				case 3:
					str	=	StaticIni.getSwfLangStr("1000000435");
					break;
				case 4:
					str	=	StaticIni.getSwfLangStr("1000000436");
					break;
				case 5:
					str =	StaticIni.getSwfLangStr("1000000437");
					break;
				case 6:
					str	=	StaticIni.getSwfLangStr("1000000438");
					break;
			}
			return str;
		}
	}
}